<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //给window对象添加监听事件
        window.onload = function() {
            //得到盒子box1
            var box1 = document.getElementById('box1')
                //得到盒子box2
            var box2 = document.getElementById('box2')
            console.log(box1);
            console.log(box2);
        }
    </script>
</head>

<body>
    <div id="box1">我是盒子1</div>
    <div id="box2">我是盒子2</div>



</body>

</html>